class Request:
    def __init__(self, request):
        self.raw_request = request
        self.request = self.raw_request.split("\r\n")

    def get_url(self):
        if "/" in self.request[0]:
            return self.request[0].split(" ")[1].split("?")[0]
        else:
            return None

    def getType(self):
        return self.request[0].split(" ")[0]

    def getParams(self):
        params = {}
        lis = self.request[0].split(" ")[1]
        if "?" in lis:
            lis = lis.split("?")[1].split("&")
            for i in lis:
                key, value = i.split("=")
                params.update({key: value})
        return params

    def getFormData(self):
        data = {}
        lis = self.request[-1].split("&")
        if bool(lis) and lis[0] != '':
            for i in lis:
                key, value = i.split("=")
                data.update({key: value})
        return data

    def to_string(self):
        return self.raw_request
